package com.hs.room.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.hs.room.model.archive.ArchiveApproval
import kotlinx.coroutines.flow.Flow

@Dao
interface ArchiveApprovalDao {

    @Insert
    suspend fun insert(d: ArchiveApproval)

    @Update
    suspend fun update(d: ArchiveApproval): Int

    @Query("SELECT * FROM archive_approval where :name = archiveUID")
    fun selectByName(name: String): ArchiveApproval

    @Query("SELECT * FROM archive_approval")
    fun getAll(): Flow<List<ArchiveApproval>>

    @Query("SELECT * FROM archive_approval ORDER BY localId LIMIT :limit OFFSET :offset ")
    fun get(limit: Int, offset: Int): Flow<List<ArchiveApproval>>

    @Query("SELECT count(*) FROM archive_approval")
    fun count(): Int

    @Delete
    suspend fun delete(d: ArchiveApproval)
}